<template>
  <el-avatar
    :src="user.avatar"
    :size="32"
    style="margin-left: 20px; cursor: pointer;"
  >
    {{ avatarText }}
  </el-avatar>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'NcAvatar',

  computed: {
    ...mapState(['user']),
    avatarText() {
      if (this.user && this.user.hasLogined) {
        if (this.user.avatar) return ''
        if (this.user.nickname) return this.user.nickname[0].toUpperCase()
      }
      return '登录'
    },
  },
}
</script>

<style scoped></style>
